********************************************************************************
****         a. Initialize                                                  ****
********************************************************************************
replace C40BPLRAW = proper(C40BPLRAW)
gen     C40BPL =   .

********************************************************************************
****         b. United States                                               ****
********************************************************************************
replace C40BPL =  41 if strpos(C40BPLRAW,"Alabama"                       ) > 0 & C40BPL == .
replace C40BPL =  81 if strpos(C40BPLRAW,"Alaska"                        ) > 0 & C40BPL == .
replace C40BPL =  61 if strpos(C40BPLRAW,"Arizona"                       ) > 0 & C40BPL == .
replace C40BPL =  42 if strpos(C40BPLRAW,"Arkansas"                      ) > 0 & C40BPL == .
replace C40BPL =  71 if strpos(C40BPLRAW,"California"                    ) > 0 & C40BPL == .
replace C40BPL =  62 if strpos(C40BPLRAW,"Colorado"                      ) > 0 & C40BPL == .
replace C40BPL =   1 if strpos(C40BPLRAW,"Connecticut"                   ) > 0 & C40BPL == .
replace C40BPL =  11 if strpos(C40BPLRAW,"Delaware"                      ) > 0 & C40BPL == .
replace C40BPL =  98 if strpos(C40BPLRAW,"District Of Columbia"          ) > 0 & C40BPL == .
replace C40BPL =  43 if strpos(C40BPLRAW,"Florida"                       ) > 0 & C40BPL == .
replace C40BPL =  44 if strpos(C40BPLRAW,"Georgia"                       ) > 0 & C40BPL == .
replace C40BPL =  82 if strpos(C40BPLRAW,"Hawaii"                        ) > 0 & C40BPL == .
replace C40BPL =  63 if strpos(C40BPLRAW,"Idaho"                         ) > 0 & C40BPL == .
replace C40BPL =  21 if strpos(C40BPLRAW,"Illinois"                      ) > 0 & C40BPL == .
replace C40BPL =  22 if strpos(C40BPLRAW,"Indiana"                       ) > 0 & C40BPL == .
replace C40BPL =  31 if strpos(C40BPLRAW,"Iowa"                          ) > 0 & C40BPL == .
replace C40BPL =  32 if strpos(C40BPLRAW,"Kansas"                        ) > 0 & C40BPL == .
replace C40BPL =  51 if strpos(C40BPLRAW,"Kentucky"                      ) > 0 & C40BPL == .
replace C40BPL =  45 if strpos(C40BPLRAW,"Louisiana"                     ) > 0 & C40BPL == .
replace C40BPL =   2 if strpos(C40BPLRAW,"Maine"                         ) > 0 & C40BPL == .
replace C40BPL =  52 if strpos(C40BPLRAW,"Maryland"                      ) > 0 & C40BPL == .
replace C40BPL =   3 if strpos(C40BPLRAW,"Massachusetts"                 ) > 0 & C40BPL == .
replace C40BPL =  23 if strpos(C40BPLRAW,"Michigan"                      ) > 0 & C40BPL == .
replace C40BPL =  33 if strpos(C40BPLRAW,"Minnesota"                     ) > 0 & C40BPL == .
replace C40BPL =  46 if strpos(C40BPLRAW,"Mississippi"                   ) > 0 & C40BPL == .
replace C40BPL =  34 if strpos(C40BPLRAW,"Missouri"                      ) > 0 & C40BPL == .
replace C40BPL =  64 if strpos(C40BPLRAW,"Montana"                       ) > 0 & C40BPL == .
replace C40BPL =  35 if strpos(C40BPLRAW,"Nebraska"                      ) > 0 & C40BPL == .
replace C40BPL =  65 if strpos(C40BPLRAW,"Nevada"                        ) > 0 & C40BPL == .
replace C40BPL =   4 if strpos(C40BPLRAW,"New Hampshire"                 ) > 0 & C40BPL == .
replace C40BPL =  12 if strpos(C40BPLRAW,"New Jersey"                    ) > 0 & C40BPL == .
replace C40BPL =  66 if strpos(C40BPLRAW,"New Mexico"                    ) > 0 & C40BPL == .
replace C40BPL =  13 if strpos(C40BPLRAW,"New York"                      ) > 0 & C40BPL == .
replace C40BPL =  47 if strpos(C40BPLRAW,"North Carolina"                ) > 0 & C40BPL == .
replace C40BPL =  36 if strpos(C40BPLRAW,"North Dakota"                  ) > 0 & C40BPL == .
replace C40BPL =  24 if strpos(C40BPLRAW,"Ohio"                          ) > 0 & C40BPL == .
replace C40BPL =  53 if strpos(C40BPLRAW,"Oklahoma"                      ) > 0 & C40BPL == .
replace C40BPL =  72 if strpos(C40BPLRAW,"Oregon"                        ) > 0 & C40BPL == .
replace C40BPL =  14 if strpos(C40BPLRAW,"Pennsylvania"                  ) > 0 & C40BPL == .
replace C40BPL =   5 if strpos(C40BPLRAW,"Rhode Island"                  ) > 0 & C40BPL == .
replace C40BPL =  48 if strpos(C40BPLRAW,"South Carolina"                ) > 0 & C40BPL == .
replace C40BPL =  37 if strpos(C40BPLRAW,"South Dakota"                  ) > 0 & C40BPL == .
replace C40BPL =  54 if strpos(C40BPLRAW,"Tennessee"                     ) > 0 & C40BPL == .
replace C40BPL =  49 if strpos(C40BPLRAW,"Texas"                         ) > 0 & C40BPL == .
replace C40BPL =  67 if strpos(C40BPLRAW,"Utah"                          ) > 0 & C40BPL == .
replace C40BPL =   6 if strpos(C40BPLRAW,"Vermont"                       ) > 0 & C40BPL == .

replace C40BPL =  56 if strpos(C40BPLRAW,"West Virginia"                 ) > 0 & C40BPL == .  /* Note: this MUST be before Virginia, senn� so cazzi! ;) */

replace C40BPL =  40 if strpos(C40BPLRAW,"Virginia"                      ) > 0 & C40BPL == .
replace C40BPL =  73 if strpos(C40BPLRAW,"Washington"                    ) > 0 & C40BPL == .
replace C40BPL =  25 if strpos(C40BPLRAW,"Wisconsin"                     ) > 0 & C40BPL == .
replace C40BPL =  68 if strpos(C40BPLRAW,"Wyoming"                       ) > 0 & C40BPL == .

********************************************************************************
****         c. Foreign countries                                           ****
********************************************************************************
replace C40BPL = 150 if strpos(C40BPLRAW,"Canada"                        ) > 0 & C40BPL == .
replace C40BPL = 434 if strpos(C40BPLRAW,"Italy"                         ) > 0 & C40BPL == .
replace C40BPL = 453 if strpos(C40BPLRAW,"Germany"                       ) > 0 & C40BPL == .
replace C40BPL = 410 if strpos(C40BPLRAW,"England"                       ) > 0 & C40BPL == .
replace C40BPL = 200 if strpos(C40BPLRAW,"Mexico"                        ) > 0 & C40BPL == .
replace C40BPL = 455 if strpos(C40BPLRAW,"Poland"                        ) > 0 & C40BPL == .
replace C40BPL = 515 if strpos(C40BPLRAW,"Philippines"                   ) > 0 & C40BPL == .
replace C40BPL = 414 if strpos(C40BPLRAW,"Ireland"                       ) > 0 & C40BPL == .
replace C40BPL = 465 if strpos(C40BPLRAW,"Russia"                        ) > 0 & C40BPL == .
replace C40BPL = 110 if strpos(C40BPLRAW,"Puerto Rico"                   ) > 0 & C40BPL == .
replace C40BPL = 500 if strpos(C40BPLRAW,"China"                         ) > 0 & C40BPL == .
replace C40BPL = 450 if strpos(C40BPLRAW,"Austria"                       ) > 0 & C40BPL == .
replace C40BPL = 452 if strpos(C40BPLRAW,"Czechoslovakia"                ) > 0 & C40BPL == .
replace C40BPL = 433 if strpos(C40BPLRAW,"Greece"                        ) > 0 & C40BPL == .
replace C40BPL = 454 if strpos(C40BPLRAW,"Hungary"                       ) > 0 & C40BPL == .
replace C40BPL = 405 if strpos(C40BPLRAW,"Sweden"                        ) > 0 & C40BPL == .
replace C40BPL = 130 if strpos(C40BPLRAW,"Panama"                        ) > 0 & C40BPL == .
replace C40BPL = 404 if strpos(C40BPLRAW,"Norway"                        ) > 0 & C40BPL == .
replace C40BPL = 457 if strpos(C40BPLRAW,"Yugoslavia"                    ) > 0 & C40BPL == .
replace C40BPL = 421 if strpos(C40BPLRAW,"France"                        ) > 0 & C40BPL == .
replace C40BPL = 456 if strpos(C40BPLRAW,"Romania"                       ) > 0 & C40BPL == .
replace C40BPL = 250 if strpos(C40BPLRAW,"Cuba"                          ) > 0 & C40BPL == .
replace C40BPL = 400 if strpos(C40BPLRAW,"Denmark"                       ) > 0 & C40BPL == .
replace C40BPL = 436 if strpos(C40BPLRAW,"Portugal"                      ) > 0 & C40BPL == .
replace C40BPL = 425 if strpos(C40BPLRAW,"Netherlands"                   ) > 0 & C40BPL == .
replace C40BPL = 542 if strpos(C40BPLRAW,"Turkey"                        ) > 0 & C40BPL == .
replace C40BPL = 426 if strpos(C40BPLRAW,"Swizterland"                   ) > 0 & C40BPL == .
replace C40BPL = 438 if strpos(C40BPLRAW,"Spain"                         ) > 0 & C40BPL == .
replace C40BPL = 462 if strpos(C40BPLRAW,"Lithuania"                     ) > 0 & C40BPL == .
replace C40BPL = 401 if strpos(C40BPLRAW,"Finland"                       ) > 0 & C40BPL == .
replace C40BPL = 420 if strpos(C40BPLRAW,"Belgium"                       ) > 0 & C40BPL == .
replace C40BPL = 430 if strpos(C40BPLRAW,"Albania"                       ) > 0 & C40BPL == .
replace C40BPL = 451 if strpos(C40BPLRAW,"Bulgaria"                      ) > 0 & C40BPL == .
replace C40BPL = 501 if strpos(C40BPLRAW,"Japan"                         ) > 0 & C40BPL == .
replace C40BPL = 600 if strpos(C40BPLRAW,"Egypt"                         ) > 0 & C40BPL == .

********************************************************************************
****         d. Add labels                                                  ****
********************************************************************************
lab def pob_lbl 1 "Connecticut" 2 "Maine" 3 "Massachusetts" 4 "New Hampshire" 5 "Rhode Island" 6 "Vermont" 11 "Delaware" 12 "New Jersey" 13 "New York" 14 "Pennsylvania" 21 "Illinois" 22 "Indiana" 23 "Michigan" 24 "Ohio" 25 "Wisconsin" 31 "Iowa" 32 "Kansas" 33 "Minnesota" 34 "Missouri" 35 "Nebraska" 36 "North Dakota" 37 "South Dakota" 40 "Virginia" 41 "Alabama" 42 "Arkansas" 43 "Florida" 44 "Georgia" 45 "Louisiana" 46 "Mississippi" 47 "North Carolina" 48 "South Carolina" 49 "Texas" 51 "Kentucky" 52 "Maryland" 53 "Oklahoma" 54 "Tennessee" 56 "West Virginia" 61 "Arizona" 62 "Colorado" 63 "Idaho" 64 "Montana" 65 "Nevada" 66 "New Mexico" 67 "Utah" 68 "Wyoming" 71 "California" 72 "Oregon" 73 "Washington" 81 "Alaska" 82 "Hawaii" 98 "District Of Columbia" 110 "Puerto Rico" 130 "Panama" 150 "Canada" 200 "Mexico" 250 "Cuba" 400 "Denmark" 401 "Finland" 404 "Norway" 405 "Sweden" 410 "England" 414 "Ireland" 420 "Belgium" 421 "France" 425 "Netherlands" 426 "Swizterland" 430 "Albania" 433 "Greece" 434 "Italy" 436 "Portugal" 438 "Spain" 450 "Austria" 451 "Bulgaria" 452 "Czechoslovakia" 453 "Germany" 454 "Hungary" 455 "Poland" 456 "Romania" 457 "Yugoslavia" 462 "Lithuania" 465 "Russia" 500 "China" 501 "Japan" 515 "Philippines" 542 "Turkey" 600 "Egypt"
lab val C40BPL  pob_lbl
